/*
 Copyright (c) 2011 LIX, Ecole Polytechnique, Palaiseau, France

 Title: hazmat variator
 Description: variator for the problem of routing hazardous material in a graph
 Copyright: Copyright (c) 2011
 Company: Ecole Polytechnique
 Authors: Nora Touati-Moungla and Dimo Brockhoff, Ecole Polytechnique, France
 Authors (previous Java version): Tamara Ulrich, ETH Zurich, Switzerland
 */

#ifndef FILEMANAGER_H_
#define FILEMANAGER_H_

#include <vector>
#include <string>

#include "Variator.h"

using namespace std;

/** Handles access to the communication files. It contains methods to read and write the state file and
 * to read out the archive file and the selector file (which are both generated by the selector).
 *
 * @author Tamara Ulrich
 * @version 1.0
 */
class FileManager {
	//PrintWriter writer;
	//FileReader reader;
	//StreamTokenizer token;

	int test;

//public:

	/** Writes the state given in the argument to the state file. The given state has to be a single integer number.
	 *
	 * @param newState the state which has to be written to the state file
	 */
	void writeState(int newState);

	/** Reads and returns the state in the state file. The state file must contain a single integer number.
	 *
	 * @return the number of the current state
	 */
	int readState();

	/** Reads the values of an archive or selector file and stores them in an integer vector. Writes 0 into the file
	 * to indicate that it has been read (to prevent multiple readouts). The archive and selector files start with
	 * the number of elements (which is also the length of the return array) and then one element per line, ending
	 * with an <code>END</code> tag on the last line. Each element consists of a single integer number which indicates
	 * the index of the individual in the global population.
	 * <p>
	 * The method terminates if the file contains a single 0, as this means that the file has already been read, which
	 * indicates an error.
	 *
	 * @param filename the name of the file to be read (e.g. "./PISA_arc" or "./PISA_sel"
	 * @return an array where the values in the file are stored
	 */
	vector<int> readArcSelFile(string filename);

};

#endif /* FILEMANAGER_H_ */
